--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_x_kitcho_yachie = General:new(extension, "hy_x_kitcho_yachie", "x_k", 3, 3, General.Female)
    local wicked_hell = fk.CreateSkill {
        name = "wicked_hell",
    }
    wicked_hell:addEffect(fk.EventPhaseStart, {
        anim_type = "defensive",
        can_trigger = function(self, event, target, player, data)
            local types = { "basic", "trick", "equip" }
            local valid = table.clone(types)
            for _, t in ipairs(player:getTableMark("@wicked_hell_record")) do
                table.removeOne(valid, t:Remove("_red"):Remove("_brief"))
            end
            event:setCostData(self, valid)
            return player:hasSkill(self) and #valid > 0 and player.phase == Player.Finish
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local result = room:askToChoice(player, {
                choices = event:getCostData(self),
                skill_name = wicked_hell.name,
                prompt = "wicked_hell_prompt",
                all_choices = { "basic", "trick", "equip" }
            })
            local marks = player:getTableMark("@wicked_hell_record")
            table.insertIfNeed(marks, result .. "_brief_red")
            room:setPlayerMark(player, "@wicked_hell_record", marks)
        end,
    })
    wicked_hell:addEffect(fk.TurnStart, {
        can_refresh = function(self, event, target, player, data)
            return player:hasSkill(self) and player == target
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            local marks = {}
            for _, str in ipairs(player:getTableMark("@wicked_hell_record")) do
                table.insertIfNeed(marks, str:Remove("_red"))
            end
            room:setPlayerMark(player, "@wicked_hell_record", marks)
        end
    })
    wicked_hell:addEffect(fk.EventPhaseStart, {
        can_refresh = function(self, event, target, player, data)
            event:setCostData(self, table.filter(player.room.alive_players, function(t)
                return table.any(t:getTableMark("@wicked_hell_record"), function(str)
                    return str:With("_red")
                end) and t ~= player and t:hasSkill("wicked_hell")
            end))
            return #event:getCostData(self) > 0 and player.phase == Player.Finish
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            local source = event:getCostData(self)[1]
            local cardType = table.find(source:getTableMark("@wicked_hell_record"), function(str)
                return str:With("_red")
            end):Remove("_red")
            local choices = { "wicked_hell_give", "wicked_hell_use", "wicked_hell_loseHp" }
            local valid = table.clone(choices)
            if #table.filter(player:getCardIds("h"), function(id)
                    local card = Fk:getCardById(id)
                    return HY.GetCardTypeString(card, true) == cardType and #table.filter(room:getOtherPlayers(source), function(t)
                        return player:canUseTo(card, t, { bypass_times = true })
                    end) > 0
                end) == 0 then
                table.removeOne(valid, "wicked_hell_use")
            end
            if #table.filter(player:getCardIds("he"), function(id)
                    local card = Fk:getCardById(id)
                    return HY.GetCardTypeString(card, true) == cardType
                end) == 0 then
                table.removeOne(valid, "wicked_hell_give")
            end
            local result = room:askToChoice(player, {
                choices = valid,
                skill_name = wicked_hell.name,
                prompt = "wicked_hell_prompt_choose",
                all_choices = choices
            })
            if result == "wicked_hell_use" then
                local cardIds = table.filter(player:getCardIds("h"), function(id)
                    local card = Fk:getCardById(id)
                    return HY.GetCardTypeString(card, true) == cardType and #table.filter(room:getOtherPlayers(source), function(t)
                        return player:canUseTo(card, t, { bypass_times = true })
                    end) > 0
                end)
                room:setPlayerMark(source, "wicked_hell", cardIds)
                local use = room:askToUseRealCard(player, {
                    pattern = cardIds,
                    skill_name = wicked_hell.name,
                    prompt = "wicked_hell_prompt_use",
                    extra_data = { exclusive_targets = table.map(room:getOtherPlayers(source), Util.IdMapper) },
                    skip = true,
                    cancelable = false,
                })
                room:setPlayerMark(source, "wicked_hell", nil)
                if use then
                    use.nullifiedTargets = use.nullifiedTargets or {}
                    table.insertIfNeed(use.nullifiedTargets, source)
                    room:useCard(use)
                    room:drawCards(source, 1, wicked_hell.name)
                end
            elseif result == "wicked_hell_give" then
                local giveCard = room:askToCards(player, {
                    min_num = 1,
                    max_num = 1,
                    include_equip = true,
                    skill_name = wicked_hell.name,
                    cancelable = false,
                    pattern = ".|.|.|hand,equip|.|" .. cardType:Remove("_brief"),
                    prompt = "wicked_hell_prompt_give"
                })
                room:moveCardTo(giveCard, Card.PlayerHand, source, fk.ReasonGive, wicked_hell.name, nil, false, player)
                room:drawCards(player, 1, wicked_hell.name)
            else
                room:loseHp(player, 1, wicked_hell.name)
            end
        end,
    })
    wicked_hell:addEffect(fk.PreCardUse, {
        mute = true,
        can_trigger = function(self, event, target, player, data)
            local marks = table.map(player:getTableMark("@wicked_hell_record"), function(mark)
                return string.Remove(mark, "_red")
            end)
            return player:hasSkill("wicked_hell") and table.contains(marks, HY.GetCardTypeString(data.card, true)) and
                player.phase ~= Player.NotActive
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            data.disresponsiveList = player.room:getOtherPlayers(player)
        end
    })
    wicked_hell:addEffect("prohibit", {
        is_prohibited = function(self, from, to, card)
            if card and from and table.contains(from:getTableMark("wicked_hell"), card.id) and to == from then
                return true
            end
        end,
    })
    local destroy_belief = fk.CreateSkill {
        name = "destroy_belief",
    }
    destroy_belief:addEffect(fk.BuryVictim, {
        anim_type = "negative",
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(self) and data.damage and data.damage.from and data.damage.from == player
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            room:setPlayerMark(player, "@wicked_hell_record", 0)
        end,
    })
    extension:loadSkillSkels { wicked_hell, destroy_belief }
    hy_x_kitcho_yachie:addSkill("wicked_hell")
    hy_x_kitcho_yachie:addSkill("destroy_belief")
    Fk:loadTranslationTable {
        ["hy_x_kitcho_yachie"] = "吉吊八千慧",
        ["#hy_x_kitcho_yachie"] = "人之心牢",
        ["illustrator:hy_x_kitcho_yachie"] = "MATSUFOX",
        ["designer:hy_x_kitcho_yachie"] = "黑曜人形",
        ["cv:hy_x_kitcho_yachie"] = "",

        ["wicked_hell"] = "邪狱",
        [":wicked_hell"] = "结束阶段，你声明一种未以此法声明过的卡牌类型。若如此做，直到你的下个回合开始：其他角色的结束阶段，其选择一项：1.使用一张此类型的手牌（不能以你为目标）并令你摸一张牌；2.交给你一张此类型的牌并摸一张牌；3.失去1点体力。你的回合内，其他角色不能响应你声明过的类型的牌。",
        ["@wicked_hell_record"] = "邪狱",
        ["wicked_hell_prompt"] = "邪狱：选择一个类型",
        ["wicked_hell_use"] = "使用牌",
        ["wicked_hell_give"] = "交出牌",
        ["wicked_hell_loseHp"] = "失去体力",
        ["wicked_hell_prompt_choose"] = "邪狱：你须选择一项",
        ["wicked_hell_prompt_use"] = "邪狱：你须使用一张牌",
        ["wicked_hell_prompt_give"] = "邪狱：你须交出一张牌",

        ["destroy_belief"] = "灭信",
        [":destroy_belief"] = "在你杀死一名角色后，重置“邪狱”。",
    }
end
